#include "../begonia.h"
#include "../bullet/condbullet.h"
#include "boss_2_2.h"
#include "../base/scene.h"

boss_2_2::boss_2_2():boss(192.0,250.0,20.0,0.0,0.0,&f.head)
    {
        int j;
        double theta;
        for(j=0;j<100;j++)
        {
            theta=M_PI*j/50.0;
            a[j]=new condbullet(x+sin(theta)*150.0,y+cos(theta)*150.0,8.0,0.0,0.0,&f.head);
        }
        for(j=0;j<40;j++)
        {
            theta=M_PI*j/20.0;
            b[j]=new condbullet(f.px+sin(theta)*60.0,f.py+cos(theta)*60.0,8.0,0.0,0.0,&f.head);
            b[j]->on=false;
        }
        for(j=0;j<20;j++)
        {
            theta=M_PI*j/10.0;
            c[j]=new condbullet(x+sin(theta)*25.0,y+cos(theta)*25.0,8.0,0.0,0.0,&f.head);
            c[j]->on=false;
        }
        mx=f.px;my=f.py;
    }
boss_2_2::boss_2_2(double tx,double ty,double tr,double tvx,double tvy,bullet *h):boss(tx,ty,tr,tvx,tvy,h)
    {
    }
    void boss_2_2::clone(bullet *h)
    {
        new boss_2_2(x,y,r,vx,vy,h);
    }
    bool boss_2_2::move()
    {
        int j;
        for(j=0;j<100;j++)
        {
            a[j]->on=sqr(a[j]->x-mx)+sqr(a[j]->y-my)>3600.0;
        }
        for(j=0;j<40;j++)
        {
            double theta=M_PI*j/20.0,temp;
            b[j]->x=mx+sin(theta)*60.0;
            b[j]->y=my+cos(theta)*60.0;
            temp=sqr(b[j]->x-x)+sqr(b[j]->y-y);
            b[j]->on=temp<22500.0&&temp>625.0;
        }
        for(j=0;j<20;j++)
        {
            c[j]->on=sqr(c[j]->x-mx)+sqr(c[j]->y-my)<3600.0;
        }
        if(sqr(mx-f.px)+sqr(my-f.py)>sqr((t-tlast)*1.0))
        {
            double theta=atan2(f.py-my,f.px-mx);
            mx+=cos(theta)*(t-tlast)*1.0;
            my+=sin(theta)*(t-tlast)*1.0;
        }
        else {mx=f.px;my=f.py;}
        if(((int)t+295)/300>((int)tlast+295)/300)
        {
            for(j=0;j<=48;j++)
            {
                new bullet(j*8.0,sch,8.0,0.0,-2.0,&f.head);
            }
        }
        else if((int)t/5>(int)tlast/5)
        {
            new bullet(rand()%(scw+1),sch,8.0,(rand()%201-100)*0.01,-2.0,&f.head);
        }
        return true;
    }
